
// "viewissues" Function to handle forms
// form change handler
targetName = target.get("name");
inputValues = form.get("values");
option = List();
actions = list();
if(targetName.equalsIgnoreCase("portals"))
{
	portalID = inputValues.get("portals").get("value");
	res = invokeurl
	[
		url :"https://projectsapi.zoho.com/restapi/portal/" + portalID + "/projects/"
		type :GET
		connection:"ENTER YOUR CONNECTION NAME"
	];
	if(!res.get("projects").isEmpty())
	{
		projects = res.get("projects");
		for each  project in projects
		{
			entry = Map();
			entry.put("label",project.get("name"));
			entry.put("value",project.get("id"));
			option.add(entry);
		}
		actions.add({"type":"add_after","name":"portals","input":{"type":"select","name":"project","label":"Project","hint":"Projects associated with portal are listed here","placeholder":"Pick a project","mandatory":true,"value":"list","options":option,"trigger_on_change":true}});
	}
	actions.add({"type":"remove","name":"tasklist"});
	actions.add({"type":"remove","name":"task"});
}
if(targetName.equalsIgnoreCase("project"))
{
	portalID = inputValues.get("portals").get("value");
	projectID = inputValues.get("project").get("value");
	res = invokeurl
	[
		url :"https://projectsapi.zoho.com/restapi/portal/" + portalID + "/projects/" + projectID + "/bugs/"
		type :GET
		connection:"ENTER YOUR CONNECTION NAME"
	];
	if(!res.get("bugs").isEmpty())
	{
		bugs = res.get("bugs");
		for each  bug in bugs
		{
			entry = Map();
			entry.put("label",bug.get("title"));
			entry.put("value",bug.get("id"));
			option.add(entry);
		}
		actions.add({"type":"add_after","name":"project","input":{"type":"select","name":"issue","label":"Issues","hint":"All issues of the selected project are listed here","placeholder":"Select an issue","mandatory":true,"value":"list","options":option}});
	}
}
return {"type":"form_modification","actions":actions};
